<%-- 
    Document   : PartnerHome
    Created on : Sep 30, 2011, 10:23:49 PM
    Author     : Belinda
--%>

<%@page import="EntityState.PartnerAccountState"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList, BusinessLogic.Constants, EntityState.TCubeAccountState" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>FoodSage Partner Administration</title>
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery-1.6.4.min.js"></script>
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery.form.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/fieldsetCollapse.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/tcubmenu.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/accordion.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/scroller.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/Utilities.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/detect_timezone.js"></script>

        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/gridsys.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/reset1.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcube.css" />
        <link href="../TransactWeb/css/gridsys.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcubaccd.css" />
        <script type="text/javascript">
            // Check Session to show relevant menus
            // Be sure to import Utilities.js in the script file	and declare partnerMenu as a servelet element
            window.onload = showPage('partnerMenu', 'leftnav');

<%
                    ArrayList data = (ArrayList) request.getAttribute("data");
                    int result = ((Integer) data.get(0)).intValue();
                    if (result == Constants.STATUS_NEW_SESSION) {
                %>
            // If not logged in, use : 
            window.onload = showPage('topMenu', 'topmenu');
            //<% } else {%>
            //IF logged in use : 
            window.onload = showPage('topMenulogout', 'topmenu');
          <% }%>
            //welcome msg
            window.onload = showPage('welcomeMenu','welcome');
            
            //footer
            window.onload = showPage('partnerFooter','footer');
            
            $(document).ready(function() {
                $.ajax({
                    type: "GET",
                    cache: false,
                    url:  "GetInfo",
                    data: {
                        action: <%= Constants.GET_LIST_OF_PARTNER_CATEGORIES%>
                    },
                    success: function(response) { 
                        var categoryIDs = [];
                        var itemIDs     = [];
                        categoryIDs.push('<option value="0">Select a Category</option>');
                        itemIDs.push('<option>Select an Item</option>');
                        $(response).find("category").each(function() {
                            // Get category info
                            var id = $(this).find("catID").text();
                            var name = $(this).find("catName").text();
                            categoryIDs.push('<option value="', 
                            id, '">', 
                            name, '</option>');
                            itemIDs.push('<option disabled="true" style="font-weight:bold;"><b>', name, '</b></option>', '<option disabled="true"/>');
                            // Get items in the category
                            $(this).find("item").each(function() {
                                var id = $(this).find("itemID").text();
                                var name = $(this).find("itemName").text();
                                itemIDs.push('<option value="', id, '">', name, '</option>');
                            });
                            itemIDs.push('<option disabled="true"/>');
                        });
                        $("#categoryID").html(categoryIDs.join(''));
                        $("#subItem").html(itemIDs.join(''));
                    }, 
                    dataType: "xml"
                });
                
                // bind 'myForm' and provide a simple callback function
                $('#addCubeForm').ajaxForm({
                    success: function(response){
                        var status = $(response).find("status").text();
                        $("#addCubeStatus").html(status);
                    },
                    dataType: "xml"
                });
                
            }); 
        </script>
    </head>
    <body>
        <div class="container_12">
            <!-- Header Nav -->   
            <div class="grid_3"><img src="../TransactWeb/img/reservation/foodsglogo.png" width="146" height="178" /></div>
            <div class="grid_9 nav">
                <div id="topmenu"></div>
            </div>
            <div class="grid_12">
                <hr size="3" color="#CC6600" />
            </div>
         
            <!-- Content -->
            <%
                    if (result == Constants.STATUS_NEW_SESSION) {
                %>

                <script type="text/javascript">
                    $(document).ready(function () {
                        var tz = jstz.determine_timezone();
                        var jsTz = tz.name();
                        document.TCubeLogin.timezone.value = jsTz;
                    });
                </script>
            <div class="grid_8 content">
                <!-- Content Header -->
                <!--Login -->
                <form action="https://localhost:8181/portal/business/PartnerLoginStatus" name="TCubeLogin" method="post">
                    <input type="hidden" id="currentURL" name="currentURL" />
                    <input type="hidden" name="timezone" id="timezone"/>
                    <table width="600" border="0" style="padding:10px 0px 10px 0px;">
                        <tr>
                            <td>
                                Username :
                            </td>
                            <td>
                                <input name="username" id="username" type="text" /> &nbsp;&nbsp; 
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Password :
                            </td>
                            <td>
                                <input name="password" id="password" type="password" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input name="login" type="submit" value="Login" />
                            </td>
                        </tr>

                    </table>
                </form>
                <!-- End Form -->
            </div>
            <!-- End Content -->
             <%  } else {
                PartnerAccountState pas = (PartnerAccountState) session.getAttribute("partner");
            %>
               <!-- Welcome Message -->
            <div class="grid_12 welcome">
                <div id="welcome"></div>
            </div>
            <!-- End Welcome Message-->

            <!-- End of Header Nav -->
            <!-- Menu / Planner -->
            <div class="grid_4">
                <div id="leftnav"></div>
            </div>
            <!--End Menu/ Planner -->
            <!-- Content -->
            <div class="grid_8 content"> Welcome to your Homepage Merchant Admin!
            </div>
            <!-- End Content -->
            <%
                }
            %>
            <!-- Footer -->
            <div class="grid_12 footer">
                <div id="footer"></div>
                </div>
            <!-- End Footer-->
        </div>
    </body>
</html>
